<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>DelimitedTextParser</title>
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="DelimitedTextParser";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../mmj/util/CommandLineArguments.html" title="class in mmj.util"><span class="strong">Prev Class</span></a></li>
<li><a href="../../mmj/util/Dump.html" title="class in mmj.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?mmj/util/DelimitedTextParser.html" target="_top">Frames</a></li>
<li><a href="DelimitedTextParser.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">mmj.util</div>
<h2 title="Class DelimitedTextParser" class="title">Class DelimitedTextParser</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>mmj.util.DelimitedTextParser</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">DelimitedTextParser</span>
extends java.lang.Object</pre>
<div class="block">Class <code>DelimitedTextParser</code> parses a line of delimited text input as a
 String.
 <p>
 DelimitedTextParser is intended for use with ASCII-delimited text files,
 which typically contain one line per record and contain text fields delimited
 by commas (',') and enclosed by quotes ('"'). A string may contain both
 quoted and unquoted fields, assuming that none of the unquoted fields contain
 occurrences of the delimiter character. Input text may contain any Unicode
 characters. Quoting may be disabled if the input data does not contain fields
 enclosed by quotes. Note that the end of the string is treated as a delimiter
 (the last field should not be terminated by a delimiter!)
 <p>
 Returned output fields consist of the characters between delimiters and
 quotes (the delimiter and quote characters are not output). Empty fields
 (adjacent delimiters) are returned as zero-length Strings (example: "a,,b"
 will return "a", "", then "b").
 <p>
 <ol>
 Parse Rules:
 <li>A line containing N delimiters contains N + 1 fields by definition.
 <li>A null string is returned from nextField after the N+1th field has been
 returned; this indicates End of Line, and a subsequent call to nextField will
 result in an IllegalArgumentException.</li>
 <li>If quotes are used for a field then there must be a pair of quotes, left
 and right, surrounding the field text and each must be adjacent to a
 delimiter or at the start or end of the line -- if another character occurs
 between a delimiter and a quote then the quote will be treated as data and
 returned as part of the parsed field (example: ('A,B"C",D') is a line
 containing 3 fields, 'A', 'B"C"', and 'D').</li>
 <li>Text inside paired quotes is returned from nextField, including
 occurrences of the defined delimiter character; if quoting is disabled then
 quote characters are always treated as data.</li>
 <li>An empty string is returned from nextField if there are no characters
 between delimiters or paired quotes, or if the line itself is an empty string
 (thus, a line consisting of just a single delimiter character contains two
 empty-string fields, by definition.)</li>
 <li>The defined quote and delimiter characters may be changed at any time
 (enabling parsing if say, the first field on a line is 'quoted' using '|'
 characters but the remaining fields are quoted using '"' characters,) the
 calling method
 </ol></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!--   -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#DelimitedTextParser()">DelimitedTextParser</a></strong>()</code>
<div class="block">Default constructor.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#DelimitedTextParser(char, char)">DelimitedTextParser</a></strong>(char&nbsp;fieldDelimiter,
                   char&nbsp;fieldQuoter)</code>
<div class="block">Constructs parser with specified quoter and delimiter parameters (note:
 quoting is enabled by default).</div>
</td>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#DelimitedTextParser(java.lang.String)">DelimitedTextParser</a></strong>(java.lang.String&nbsp;lineIn)</code>
<div class="block">Constructs parser for a String using default parse parameters.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#DelimitedTextParser(java.lang.String, char, char)">DelimitedTextParser</a></strong>(java.lang.String&nbsp;lineIn,
                   char&nbsp;fieldDelimiter,
                   char&nbsp;fieldQuoter)</code>
<div class="block">Constructs parser for a String using specified parse parameters (note:
 quoting is enabled by default).</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>char</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#getParseDelimiter()">getParseDelimiter</a></strong>()</code>
<div class="block">Returns the parse delimiter character</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>char</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#getParseQuoter()">getParseQuoter</a></strong>()</code>
<div class="block">Returns the parse quote character</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#getParseString()">getParseString</a></strong>()</code>
<div class="block">Returns the original line being parsed.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#main(java.lang.String[])">main</a></strong>(java.lang.String[]&nbsp;args)</code>
<div class="block">Test code -- just run, requires no command line params.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#nextField()">nextField</a></strong>()</code>
<div class="block">Returns the next field from the input String.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.util.List&lt;java.lang.String&gt;</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#parseAll()">parseAll</a></strong>()</code>
<div class="block">Returns a list of all fields, consuming the entire input String.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#resetParseDefaults()">resetParseDefaults</a></strong>()</code>
<div class="block">Resets the parsing parameters to their default values: delimiter = comma,
 quoter = quote, quoter is enabled.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#setParseDelimiter(char)">setParseDelimiter</a></strong>(char&nbsp;delimiter)</code>
<div class="block">Sets the parse delimiter to a specified character.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#setParseQuoter(char)">setParseQuoter</a></strong>(char&nbsp;quoter)</code>
<div class="block">Sets the parse quoter to a specified character.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#setParseString(java.lang.String)">setParseString</a></strong>(java.lang.String&nbsp;lineIn)</code>
<div class="block">Loads a new String into an existing parser and prepares the parse object
 for parsing the first field of the string.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../mmj/util/DelimitedTextParser.html#setQuoterEnabled(boolean)">setQuoterEnabled</a></strong>(boolean&nbsp;quoterEnabled)</code>
<div class="block">Enables or disables (turns on/off) quote parsing.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!--   -->
</a>
<h3>Constructor Detail</h3>
<a name="DelimitedTextParser()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>DelimitedTextParser</h4>
<pre>public&nbsp;DelimitedTextParser()</pre>
<div class="block">Default constructor.</div>
</li>
</ul>
<a name="DelimitedTextParser(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>DelimitedTextParser</h4>
<pre>public&nbsp;DelimitedTextParser(java.lang.String&nbsp;lineIn)
                    throws java.lang.IllegalArgumentException</pre>
<div class="block">Constructs parser for a String using default parse parameters.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>lineIn</code> - String to be parsed.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if an error occurred</dd></dl>
</li>
</ul>
<a name="DelimitedTextParser(char, char)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>DelimitedTextParser</h4>
<pre>public&nbsp;DelimitedTextParser(char&nbsp;fieldDelimiter,
                   char&nbsp;fieldQuoter)</pre>
<div class="block">Constructs parser with specified quoter and delimiter parameters (note:
 quoting is enabled by default).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>fieldDelimiter</code> - Delimiter character.</dd><dd><code>fieldQuoter</code> - Quote character used to enclose fields.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.NullPointerException</code> - if the input String reference is null.</dd></dl>
</li>
</ul>
<a name="DelimitedTextParser(java.lang.String, char, char)">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>DelimitedTextParser</h4>
<pre>public&nbsp;DelimitedTextParser(java.lang.String&nbsp;lineIn,
                   char&nbsp;fieldDelimiter,
                   char&nbsp;fieldQuoter)
                    throws java.lang.IllegalArgumentException</pre>
<div class="block">Constructs parser for a String using specified parse parameters (note:
 quoting is enabled by default).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>lineIn</code> - String to be parsed.</dd><dd><code>fieldDelimiter</code> - Delimiter character.</dd><dd><code>fieldQuoter</code> - Quote character used to enclose fields.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if an error occurred</dd>
<dd><code>java.lang.NullPointerException</code> - if the input String reference is null.</dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="setParseString(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setParseString</h4>
<pre>public&nbsp;void&nbsp;setParseString(java.lang.String&nbsp;lineIn)
                    throws java.lang.IllegalArgumentException</pre>
<div class="block">Loads a new String into an existing parser and prepares the parse object
 for parsing the first field of the string.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>lineIn</code> - String to be parsed.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if an error occurred</dd>
<dd><code>java.lang.NullPointerException</code> - if the input String reference is null.</dd></dl>
</li>
</ul>
<a name="getParseString()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getParseString</h4>
<pre>public&nbsp;java.lang.String&nbsp;getParseString()</pre>
<div class="block">Returns the original line being parsed.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>line String to be parsed.</dd></dl>
</li>
</ul>
<a name="setQuoterEnabled(boolean)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setQuoterEnabled</h4>
<pre>public&nbsp;void&nbsp;setQuoterEnabled(boolean&nbsp;quoterEnabled)</pre>
<div class="block">Enables or disables (turns on/off) quote parsing.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>quoterEnabled</code> - Set to true for enabled or false for disabled.</dd></dl>
</li>
</ul>
<a name="resetParseDefaults()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>resetParseDefaults</h4>
<pre>public&nbsp;void&nbsp;resetParseDefaults()</pre>
<div class="block">Resets the parsing parameters to their default values: delimiter = comma,
 quoter = quote, quoter is enabled.</div>
</li>
</ul>
<a name="setParseDelimiter(char)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setParseDelimiter</h4>
<pre>public&nbsp;void&nbsp;setParseDelimiter(char&nbsp;delimiter)</pre>
<div class="block">Sets the parse delimiter to a specified character.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>delimiter</code> - the field delimiter character.</dd></dl>
</li>
</ul>
<a name="getParseDelimiter()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getParseDelimiter</h4>
<pre>public&nbsp;char&nbsp;getParseDelimiter()</pre>
<div class="block">Returns the parse delimiter character</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>parse delimiter character</dd></dl>
</li>
</ul>
<a name="setParseQuoter(char)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setParseQuoter</h4>
<pre>public&nbsp;void&nbsp;setParseQuoter(char&nbsp;quoter)</pre>
<div class="block">Sets the parse quoter to a specified character.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>quoter</code> - character that encloses input fields.</dd></dl>
</li>
</ul>
<a name="getParseQuoter()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getParseQuoter</h4>
<pre>public&nbsp;char&nbsp;getParseQuoter()</pre>
<div class="block">Returns the parse quote character</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>parse quote character</dd></dl>
</li>
</ul>
<a name="nextField()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>nextField</h4>
<pre>public&nbsp;java.lang.String&nbsp;nextField()
                           throws java.lang.IllegalArgumentException,
                                  java.lang.IllegalStateException</pre>
<div class="block">Returns the next field from the input String.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>String the next field parsed from the input String or null if
         there are no more fields in the String.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - thrown if the string to be parsed is not
             correctly formatted (for example, unmatched quote characters)
             or if nextField invoked again after reaching the end of the
             line.</dd>
<dd><code>java.lang.IllegalStateException</code> - if an error occurred</dd></dl>
</li>
</ul>
<a name="parseAll()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>parseAll</h4>
<pre>public&nbsp;java.util.List&lt;java.lang.String&gt;&nbsp;parseAll()
                                          throws java.lang.IllegalArgumentException,
                                                 java.lang.IllegalStateException</pre>
<div class="block">Returns a list of all fields, consuming the entire input String.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>A <code>List&lt;String&gt;</code> of fields parsed from the input String.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - thrown if the string to be parsed is not
             correctly formatted (for example, unmatched quote characters)
             or if parseAll invoked again after reaching the end of the
             line.</dd>
<dd><code>java.lang.IllegalStateException</code> - if an error occurred</dd></dl>
</li>
</ul>
<a name="main(java.lang.String[])">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>main</h4>
<pre>public static&nbsp;void&nbsp;main(java.lang.String[]&nbsp;args)</pre>
<div class="block">Test code -- just run, requires no command line params.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>args</code> - not used.</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../mmj/util/CommandLineArguments.html" title="class in mmj.util"><span class="strong">Prev Class</span></a></li>
<li><a href="../../mmj/util/Dump.html" title="class in mmj.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?mmj/util/DelimitedTextParser.html" target="_top">Frames</a></li>
<li><a href="DelimitedTextParser.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
